package ar.edu.unicen.pladema.main;

import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;

import ar.edu.unicen.pladema.ui.main.GrandPanel;

/**
 * Aplicación.
 * @author Sebastian Perruolo &lt;sperruolo[at]alumnos.exa.unicen.edu.ar&gt;
 */
public final class AppShell 
		extends AbstractShell{

	/** Panel contenido en la aplicación. */
	private GrandPanel tabGroup = null;
	
	private boolean askClose = true;
	
	/**
	 * Creador.
	 */
	public AppShell(boolean askClose) {
		super(null);
		this.askClose = askClose;
	}
	/**
	 * Se ubican los componentes.
	 */
	protected void layoutWidgets() {
		shell.setLayout(new FillLayout());
		//shell.setMinimumSize(MIN_SIZE_WIDTH, MIN_SIZE_HEIGHT);
		
	}
	/**
	 * Se crean los componentes.
	 */
	protected void createWidgets() {
		shell.addListener(SWT.Close, new Listener() {
			public void handleEvent(final Event event) {
				if (askClose) {
					event.doit = Message.showYesNo(shell, "APP_CLOSE_QUESTION");
				}
			}
		});
		tabGroup = new GrandPanel(shell, SWT.BORDER_DASH);
	}

	protected void dispose() {
		if (tabGroup == null) return;
		tabGroup.dispose();
	}
}
